package com.itheima.test01;

import com.itheima.test01.config.SpringConfig;
import com.itheima.test01.service.IUserService;
import com.itheima.test01.service.UserService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test {
    @Test
    public void test() {
//        UserService userService = new UserService();
//        userService.getUser();

        // 依赖注入
//        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("test01.xml");
//        IUserService service = ioc.getBean(IUserService.class);
//        service.getUser();

        //
        AnnotationConfigApplicationContext ioc = new AnnotationConfigApplicationContext(SpringConfig.class);
        IUserService service = ioc.getBean(IUserService.class);
        service.getUser();
    }
}
